package com.service.wmt.impl;

import com.dao.PreSaleDAO;
import com.dao.ServiceDao;
import com.entity.PreSaleService;
import com.entity.Service;
import com.entity.ServiceExample;
import com.entity.WmtBuildingList;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.service.wmt.ServiceService;
import com.util.gzp.AjaxResponse;

import javax.annotation.Resource;
import java.util.List;

@org.springframework.stereotype.Service
public class ServiceServiceImpl implements ServiceService {

    @Resource
    private ServiceDao serviceDao;
    @Resource
    private PreSaleDAO preSaleDAO;

    @Override
    public List<Service> findServiceNotOk() {
        ServiceExample example = new ServiceExample();
        ServiceExample.Criteria criteria = example.createCriteria();
        criteria.andApplicationIsNotNull();
        criteria.andIdcopyIsNotNull();
        List<Service> serviceList = serviceDao.selectByExample(example);
        return serviceList;
    }

    @Override
    public AjaxResponse findAll(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<PreSaleService> list =preSaleDAO.findAll();
        PageInfo<PreSaleService> pageInfo = new PageInfo<>(list);
        return AjaxResponse.success(pageInfo);
    }

    @Override
    public PreSaleService findByServiceid(Integer serviceid) {
        return preSaleDAO.findByServiceid(serviceid);
    }


    @Override
    public Service findById(Integer serviceid) {
        return serviceDao.selectByPrimaryKey(serviceid);
    }

    @Override
    public Integer changeStatu(Service service) {
        service.setServicestatusid(2);
        serviceDao.updateByPrimaryKeySelective(service);
        return null;
    }


}
